<?php
/*
	获取活动信息
	问题，朋友圈商城是否所有的商品都作为活动商品？是！那么活动插件标识在何时加入？新增商品时！
*/
defined('BY_JYA') or exit('error');
list($goods_id,$active_id,$num)=$arguments;
$member=$this->get('member',array('mid'=>$_SESSION['uid']));
$mygoods=array();
if($member['is_agent']){
	$goods=$this->get('goods',array('goods_id'=>$goods_id));
	if($goods['isdiyprice']){
		$goods['diyprice']=$goods['diyprice']?json_decode($goods['diyprice'],true):array();
		if($goods['diyprice']){
			foreach($goods['diyprice'] as $dv){
				if($member['level_id']==$dv['levelid']){
					$mygoods['price']=$dv['price'];
					$isdiyprice=true;
					break;
				}
			}
		}
	}
}
if($member['agent_id'] && !$isdiyprice){
	if($member['dian_mid']){
		$mygoods=$this->get('mygoods',array('mid'=>$member['dian_mid'],'goodsid'=>$goods_id));
	}elseif($member['daili_id']){
		$mygoods=$this->get('mygoods',array('mid'=>$member['daili_id'],'goodsid'=>$goods_id));
	}else{
		$agent=$this->get('member',array('mid'=>$member['agent_id']));
		$agent_id=$agent['dian_mid']?:$member['agent_id'];
		$mygoods=$this->get('mygoods',array('mid'=>$agent_id,'goodsid'=>$goods_id));
	}
}
if($mygoods['total']<$num && $mygoods['id']){
	exi('库存不足！当前库存'.$mygoods['total'],'error');
}
return true;
